package com.demo.design;

import com.demo.design.store.ICommodity;
import com.demo.design.store.impl.CardCommodityService;
import com.demo.design.store.impl.CouponCommodityService;
import com.demo.design.store.impl.GoodsCommodityService;

/**
 * @author: ling007
 * @date: 2024/8/27 16:43
 * @description:
 */

public class StoreFactory {

    public ICommodity getCommodityService(Integer commodityType){
        if (null == commodityType) return null;
        if (1 == commodityType) return new CouponCommodityService();
        if (2 == commodityType) return new GoodsCommodityService();
        if (3 == commodityType) return new CardCommodityService();
        throw new RuntimeException("不不存在的商品服务类型");
    }
}
